
package com.ffcs.crmd.tsp.admin.facade.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ctg.itrdc.platform.common.entity.PageInfo;
import com.ctg.itrdc.platform.common.utils.bean.BeanUtils;
import com.ffcs.crmd.platform.core.ddd.facade.impl.AbstractCrmDomFacade;
import com.ffcs.crmd.tsp.admin.api.dto.JobDetailParamDTO;
import com.ffcs.crmd.tsp.admin.api.facade.IJobDetailParamFacade;
import com.ffcs.crmd.tsp.admin.entity.JobDetailParam;
import com.ffcs.crmd.tsp.admin.service.IJobDetailParamService;

@Service("jobDetailParamFacade")
public class JobDetailParamFacadeImpl extends AbstractCrmDomFacade implements IJobDetailParamFacade {
    
    @Autowired
    private IJobDetailParamService jobDetailParamService;
    
    @Override
    public JobDetailParamDTO get(JobDetailParamDTO jobDetailParamDTO) throws Exception {
        JobDetailParam jobDetailParam = new JobDetailParam();
        BeanUtils.applyIf(jobDetailParam, jobDetailParamDTO, false);
        JobDetailParam rjobDetailParam = jobDetailParamService.get(jobDetailParam);
        
        JobDetailParamDTO rjobDetailParamDTO = new JobDetailParamDTO();
        BeanUtils.applyIf(rjobDetailParamDTO, rjobDetailParam, false);
        return rjobDetailParamDTO;
    }
    
    @Override
    public PageInfo<JobDetailParamDTO> queryPage(JobDetailParamDTO jobDetailParamDTO) throws Exception {
        JobDetailParam jobDetailParam = new JobDetailParam();
        BeanUtils.applyIf(jobDetailParam, jobDetailParamDTO, false);
        PageInfo<JobDetailParam> pageInfo = jobDetailParamService.query(jobDetailParam, jobDetailParamDTO.getPageNumber(), jobDetailParamDTO.getPageSize());
        return copyPageInfo(pageInfo);
    }
    
    
    @Override
    public void save(JobDetailParamDTO jobDetailParamDto) throws Exception {
        JobDetailParam jobDetailParam = new JobDetailParam();
        BeanUtils.applyIf(jobDetailParam, jobDetailParamDto);
        jobDetailParamService.save(jobDetailParam);
    }
    
    private PageInfo<JobDetailParamDTO> copyPageInfo(PageInfo<JobDetailParam> pageInfo) throws Exception {
        PageInfo<JobDetailParamDTO> pageInfoDto = new PageInfo<JobDetailParamDTO>();
        BeanUtils.applyIf(pageInfoDto, pageInfo, false);
        pageInfoDto.setList(BeanUtils.copyList(pageInfo.getList(), JobDetailParamDTO.class));
        return pageInfoDto;
    }

    /**
     * 功能说明:
     * 
     * @param jobDetailParamDto
     * @throws Exception
     */
    @Override
    public void delete(JobDetailParamDTO jobDetailParamDto) throws Exception {
        JobDetailParam jobDetailParam = new JobDetailParam();
        BeanUtils.applyIf(jobDetailParam, jobDetailParamDto);
        jobDetailParamService.delete(jobDetailParam);
    }

    /**
     * 功能说明:
     * 
     * @param jobDetailParamDto
     * @throws Exception
     */
    @Override
    public void update(JobDetailParamDTO jobDetailParamDto) throws Exception {
        JobDetailParam jobDetailParam = new JobDetailParam();
        BeanUtils.applyIf(jobDetailParam, jobDetailParamDto);
        jobDetailParamService.update(jobDetailParam);
    }
}
